﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;


namespace _29Jan_Tasks
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetCursorPosition(5, 10);
            //Console.WriteLine("Привет");
            //Console.ReadLine();
            //Console.Clear();
            Console.WriteLine("Введите точку на оси Х с которой хотите начать рисовать поле");
            int X = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Введите точку на оси Y с которой хотите начать рисовать поле");
            int Y = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Введите высоту поля");
            int heig = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Введите ширину поля");
            int wid = Int32.Parse(Console.ReadLine());
            Console.Clear();

            GameField gameField = new GameField(X, Y, wid, heig);
            Console.SetCursorPosition(gameField.gameFieldX, gameField.gameFieldY);
            gameField.DrawGameField(gameField, gameField.ch);
            Console.ReadLine();

            GameNode gameNode = new GameNode(X+2, Y+1, '%');
            //gameNode.DrawGameNode(gameNode);
            //Thread.Sleep(700);
            //gameNode.ClearGameNode(gameNode);
            //gameNode.MoveDown();
            //Thread.Sleep(700);
            //gameNode.DrawGameNode(gameNode);
            //Thread.Sleep(700);
            //gameNode.ClearGameNode(gameNode);
            //gameNode.MoveDown();
            //Thread.Sleep(700);
            //gameNode.DrawGameNode(gameNode);
            //Thread.Sleep(700);
            //gameNode.ClearGameNode(gameNode);
            //gameNode.MoveDown();
            //Thread.Sleep(700);
            gameNode.DrawGameNode(gameNode);
            Thread.Sleep(700);
            gameNode.ClearGameNode(gameNode);
            gameNode.MoveDown();
            
            

        }
    }

    class GameField
    {
        public int gameFieldX;
        public int gameFieldY;
        public int width;
        public int height;
        public char ch = '*';
        //public bool[,] myArray = new bool[gameFieldX, gameFieldY];


        public GameField(int gameFieldX, int gameFieldY, int width, int height)
        {
            this.gameFieldX = gameFieldX;
            this.gameFieldY = gameFieldY;
            this.width = width;
            this.height = height;
        }

        public int SetFieldWidth
        {
            get
            {
                return width;
            }
            set
            {
                width = value;
            }
        }

        public int SetFieldHeight
        {
            get
            {
                return height;
            }
            set
            {
                height = value;
            }
        }

        public int SetGameFieldX
        {
            get
            {
                return gameFieldX;
            }
            set
            {
                gameFieldX = value;
            }
        }

        public int SetGameFieldY
        {
            get
            {
                return gameFieldY;
            }
            set
            {
                gameFieldY = value;
            }
        }

        public void DrawGameField(GameField gameField, char ch)
        {
            for (int i = gameField.gameFieldY; i <= gameField.height + gameField.gameFieldY - 1; i++)
            {
                for (int j = gameField.gameFieldX; j <= gameField.width + gameFieldX - 1; j++)
                {
                    if (i == gameField.gameFieldY || i == (gameField.gameFieldY + gameField.height - 1) || j == gameField.gameFieldX || j == (gameField.gameFieldX + gameField.width - 1))
                    {
                        Console.SetCursorPosition(i, j);
                        Console.Write(ch);
                    }
                    else
                        Console.Write(" ");
                }
                Console.WriteLine();
            }
        }
    }


    class GameNode
    {
        public int X { get; private set; }
        public int Y { get; private set; }
        public char GameNodeSymbol { get; private set; }

        public GameNode(int x, int y, char gn)
        {
            X = x;
            Y = y;
            GameNodeSymbol = gn;
        }

        public void MoveUp()
        {
            Y--;
        }

        public void MoveDown()
        {
            Y++;
        }

        public void MoveLeft()
        {
            X--;
        }

        public void MoveRight()
        {
            X++;
        }

        public void DrawGameNode (GameNode gameNode)
        {
            Console.SetCursorPosition(gameNode.X+1, gameNode.Y+1);
            Console.Write(GameNodeSymbol);
        }

        public void ClearGameNode(GameNode gameNode)
        {
            Console.SetCursorPosition(gameNode.X+1, gameNode.Y+1);
            Console.Write(' ');
        }

    }
}   

